package org.neptune.service.config;

import org.neptune.service.interceptor.IpInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author lwl
 * @date 2019/8/6 17:18
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

	// 处理拦截器里面属性注入是null的问题
	@Bean
	public IpInterceptor getIpInterceptor() {
		return new IpInterceptor();
	}

	@Override
	public void addInterceptors(InterceptorRegistry registry) {

		registry.addInterceptor(getIpInterceptor()).addPathPatterns("/seckillGoodsInfo", "/seckill")
				.excludePathPatterns("/static/**").excludePathPatterns("/error");
	}
}
